const Sequelize = require('sequelize');
const hostConfig = require('./host');

const sequelize = new Sequelize('你的数据库名字', '数据库用户名', '数据库密码', {
  // 服务器的ip
  host: hostConfig.host,
  dialect: 'mysql',
  dialectOptions: {
    charset: 'utf8mb4',
    supportBigNumbers: true,
    bigNumberStrings: true,
  },
  pool: {
    max: 5,
    min: 0,
    acquire: 30000,
    idle: 10000,
  },
  define: {
    timestamps: true,
  },
  timezone: '+08:00',
});
// 数据库测试连接可以取消注释
// sequelize
//   .authenticate()
//   .then(() => {
//     console.log('Connection has been established successfully.');
//   })
//   .catch((err) => {
//     console.error('Unable to connect to the database:', err);
//   });
module.exports = { sequelize };
